package be.gnx.fogo.application.util;

import java.io.Serializable;
import java.sql.Connection;
import java.util.Map;
import java.util.Set;

import javax.naming.NamingException;
import javax.naming.Reference;

import org.hibernate.CacheMode;
import org.hibernate.Criteria;
import org.hibernate.EntityMode;
import org.hibernate.Filter;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.ReplicationMode;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.StatelessSession;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.engine.FilterDefinition;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.stat.SessionStatistics;
import org.hibernate.stat.Statistics;

public class HibernateUtil {

  private static final SessionFactory sessionFactory;

  static {
    try {
      // Create the SessionFactory from hibernate.cfg.xml
      sessionFactory = new Configuration().configure().buildSessionFactory();
    } catch (Throwable ex) {
      // Make sure you log the exception, as it might be swallowed
      System.err.println("Initial SessionFactory creation failed." + ex);
      throw new ExceptionInInitializerError(ex);
    }
  }

  public static SessionFactory getSessionFactory() {
    return sessionFactory;
  }

  public static void close() throws HibernateException {
    sessionFactory.close();
  }

  public static void evict(Class arg0, Serializable arg1) throws HibernateException {
    sessionFactory.evict(arg0, arg1);
  }

  public static void evict(Class arg0) throws HibernateException {
    sessionFactory.evict(arg0);
  }

  public static void evictCollection(String arg0, Serializable arg1) throws HibernateException {
    sessionFactory.evictCollection(arg0, arg1);
  }

  public static void evictCollection(String arg0) throws HibernateException {
    sessionFactory.evictCollection(arg0);
  }

  public static void evictEntity(String arg0, Serializable arg1) throws HibernateException {
    sessionFactory.evictEntity(arg0, arg1);
  }

  public static void evictEntity(String arg0) throws HibernateException {
    sessionFactory.evictEntity(arg0);
  }

  public static void evictQueries() throws HibernateException {
    sessionFactory.evictQueries();
  }

  public static void evictQueries(String arg0) throws HibernateException {
    sessionFactory.evictQueries(arg0);
  }

  public static Map getAllClassMetadata() throws HibernateException {
    return sessionFactory.getAllClassMetadata();
  }

  public static Map getAllCollectionMetadata() throws HibernateException {
    return sessionFactory.getAllCollectionMetadata();
  }

  public static ClassMetadata getClassMetadata(Class arg0) throws HibernateException {
    return sessionFactory.getClassMetadata(arg0);
  }

  public static ClassMetadata getClassMetadata(String arg0) throws HibernateException {
    return sessionFactory.getClassMetadata(arg0);
  }

  public static CollectionMetadata getCollectionMetadata(String arg0) throws HibernateException {
    return sessionFactory.getCollectionMetadata(arg0);
  }

  public static org.hibernate.classic.Session getCurrentSession() throws HibernateException {
    return sessionFactory.getCurrentSession();
  }

  public static Set getDefinedFilterNames() {
    return sessionFactory.getDefinedFilterNames();
  }

  public static FilterDefinition getFilterDefinition(String arg0) throws HibernateException {
    return sessionFactory.getFilterDefinition(arg0);
  }

  public static Reference getReference() throws NamingException {
    return sessionFactory.getReference();
  }

  public static Statistics getStatistics() {
    return sessionFactory.getStatistics();
  }

  public static boolean isClosed() {
    return sessionFactory.isClosed();
  }

  public static org.hibernate.classic.Session openSession() throws HibernateException {
    return sessionFactory.openSession();
  }

  public static org.hibernate.classic.Session openSession(Connection arg0, Interceptor arg1) {
    return sessionFactory.openSession(arg0, arg1);
  }

  public static org.hibernate.classic.Session openSession(Connection arg0) {
    return sessionFactory.openSession(arg0);
  }

  public static org.hibernate.classic.Session openSession(Interceptor arg0) throws HibernateException {
    return sessionFactory.openSession(arg0);
  }

  public static StatelessSession openStatelessSession() {
    return sessionFactory.openStatelessSession();
  }

  public static StatelessSession openStatelessSession(Connection arg0) {
    return sessionFactory.openStatelessSession(arg0);
  }

  public static Transaction beginTransaction() throws HibernateException {
    return getCurrentSession().beginTransaction();
  }

  public static void cancelQuery() throws HibernateException {
    getCurrentSession().cancelQuery();
  }

  public static void clear() {
    getCurrentSession().clear();
  }

  public static Connection closeSession() throws HibernateException {
    return getCurrentSession().close();
  }

  public static boolean contains(Object arg0) {
    return getCurrentSession().contains(arg0);
  }

  public static Criteria createCriteria(Class arg0, String arg1) {
    return getCurrentSession().createCriteria(arg0, arg1);
  }

  public static Criteria createCriteria(Class arg0) {
    return getCurrentSession().createCriteria(arg0);
  }

  public static Criteria createCriteria(String arg0, String arg1) {
    return getCurrentSession().createCriteria(arg0, arg1);
  }

  public static Criteria createCriteria(String arg0) {
    return getCurrentSession().createCriteria(arg0);
  }

  public static Query createFilter(Object arg0, String arg1) throws HibernateException {
    return getCurrentSession().createFilter(arg0, arg1);
  }

  public static Query createQuery(String arg0) throws HibernateException {
    return getCurrentSession().createQuery(arg0);
  }

  public static SQLQuery createSQLQuery(String arg0) throws HibernateException {
    return getCurrentSession().createSQLQuery(arg0);
  }

  public static void delete(Object arg0) throws HibernateException {
    getCurrentSession().delete(arg0);
  }

  public static void delete(String arg0, Object arg1) throws HibernateException {
    getCurrentSession().delete(arg0, arg1);
  }

  public static void disableFilter(String arg0) {
    getCurrentSession().disableFilter(arg0);
  }

  public static Connection disconnect() throws HibernateException {
    return getCurrentSession().disconnect();
  }

  public static Filter enableFilter(String arg0) {
    return getCurrentSession().enableFilter(arg0);
  }

  public static void evict(Object arg0) throws HibernateException {
    getCurrentSession().evict(arg0);
  }

  public static void flush() throws HibernateException {
    getCurrentSession().flush();
  }

  public static Object get(Class arg0, Serializable arg1, LockMode arg2) throws HibernateException {
    return getCurrentSession().get(arg0, arg1, arg2);
  }

  public static Object get(Class arg0, Serializable arg1) throws HibernateException {
    return getCurrentSession().get(arg0, arg1);
  }

  public static Object get(String arg0, Serializable arg1, LockMode arg2) throws HibernateException {
    return getCurrentSession().get(arg0, arg1, arg2);
  }

  public static Object get(String arg0, Serializable arg1) throws HibernateException {
    return getCurrentSession().get(arg0, arg1);
  }

  public static CacheMode getCacheMode() {
    return getCurrentSession().getCacheMode();
  }

  public static LockMode getCurrentLockMode(Object arg0) throws HibernateException {
    return getCurrentSession().getCurrentLockMode(arg0);
  }

  public static Filter getEnabledFilter(String arg0) {
    return getCurrentSession().getEnabledFilter(arg0);
  }

  public static EntityMode getEntityMode() {
    return getCurrentSession().getEntityMode();
  }

  public static String getEntityName(Object arg0) throws HibernateException {
    return getCurrentSession().getEntityName(arg0);
  }

  public static FlushMode getFlushMode() {
    return getCurrentSession().getFlushMode();
  }

  public static Serializable getIdentifier(Object arg0) throws HibernateException {
    return getCurrentSession().getIdentifier(arg0);
  }

  public static Query getNamedQuery(String arg0) throws HibernateException {
    return getCurrentSession().getNamedQuery(arg0);
  }

  public static Session getSession(EntityMode arg0) {
    return getCurrentSession().getSession(arg0);
  }

  public static SessionStatistics getSessionStatistics() {
    return getCurrentSession().getStatistics();
  }

  public static Transaction getTransaction() {
    return getCurrentSession().getTransaction();
  }

  public static boolean isConnected() {
    return getCurrentSession().isConnected();
  }

  public static boolean isDirty() throws HibernateException {
    return getCurrentSession().isDirty();
  }

  public static boolean isOpen() {
    return getCurrentSession().isOpen();
  }

  public static Object load(Class arg0, Serializable arg1, LockMode arg2) throws HibernateException {
    return getCurrentSession().load(arg0, arg1, arg2);
  }

  public static Object load(Class arg0, Serializable arg1) throws HibernateException {
    return getCurrentSession().load(arg0, arg1);
  }

  public static void load(Object arg0, Serializable arg1) throws HibernateException {
    getCurrentSession().load(arg0, arg1);
  }

  public static Object load(String arg0, Serializable arg1, LockMode arg2) throws HibernateException {
    return getCurrentSession().load(arg0, arg1, arg2);
  }

  public static Object load(String arg0, Serializable arg1) throws HibernateException {
    return getCurrentSession().load(arg0, arg1);
  }

  public static void lock(Object arg0, LockMode arg1) throws HibernateException {
    getCurrentSession().lock(arg0, arg1);
  }

  public static void lock(String arg0, Object arg1, LockMode arg2) throws HibernateException {
    getCurrentSession().lock(arg0, arg1, arg2);
  }

  public static Object merge(Object arg0) throws HibernateException {
    return getCurrentSession().merge(arg0);
  }

  public static Object merge(String arg0, Object arg1) throws HibernateException {
    return getCurrentSession().merge(arg0, arg1);
  }

  public static void persist(Object arg0) throws HibernateException {
    getCurrentSession().persist(arg0);
  }

  public static void persist(String arg0, Object arg1) throws HibernateException {
    getCurrentSession().persist(arg0, arg1);
  }

  public static void reconnect(Connection arg0) throws HibernateException {
    getCurrentSession().reconnect(arg0);
  }

  public static void refresh(Object arg0, LockMode arg1) throws HibernateException {
    getCurrentSession().refresh(arg0, arg1);
  }

  public static void refresh(Object arg0) throws HibernateException {
    getCurrentSession().refresh(arg0);
  }

  public static void replicate(Object arg0, ReplicationMode arg1) throws HibernateException {
    getCurrentSession().replicate(arg0, arg1);
  }

  public static void replicate(String arg0, Object arg1, ReplicationMode arg2) throws HibernateException {
    getCurrentSession().replicate(arg0, arg1, arg2);
  }

  public static Serializable save(Object arg0) throws HibernateException {
    return getCurrentSession().save(arg0);
  }

  public static Serializable save(String arg0, Object arg1) throws HibernateException {
    return getCurrentSession().save(arg0, arg1);
  }

  public static void saveOrUpdate(Object arg0) throws HibernateException {
    getCurrentSession().saveOrUpdate(arg0);
  }

  public static void saveOrUpdate(String arg0, Object arg1) throws HibernateException {
    getCurrentSession().saveOrUpdate(arg0, arg1);
  }

  public static void setCacheMode(CacheMode arg0) {
    getCurrentSession().setCacheMode(arg0);
  }

  public static void setFlushMode(FlushMode arg0) {
    getCurrentSession().setFlushMode(arg0);
  }

  public static void setReadOnly(Object arg0, boolean arg1) {
    getCurrentSession().setReadOnly(arg0, arg1);
  }

  public static void update(Object arg0) throws HibernateException {
    getCurrentSession().update(arg0);
  }

  public static void update(String arg0, Object arg1) throws HibernateException {
    getCurrentSession().update(arg0, arg1);
  }

  
}